package com.snake.common;

import com.foxinmy.weixin4j.cache.FileCacheStorager;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.model.WeixinAccount;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.mp.WeixinProxy;
import com.foxinmy.weixin4j.payment.WeixinPayProxy;


/**
 * Created by zhaohaochen on 2016/12/28.
 */
public class WeixinPayProxyManager {

    
    private static WeixinProxy weixinProxy;
    private static WeixinPayProxy weixinPayProxy;

    public static WeixinProxy getWeixinProxy(String appid,String appSecret) {

        if (weixinProxy == null) {
            weixinProxy = new WeixinProxy(new WeixinAccount(appid, appSecret),
                    new FileCacheStorager<Token>());
        }
        return weixinProxy;
    }
    public static WeixinPayProxy getWeixinPayProxy(String id,String paySignKey,String mchId,String certificateKey,String certificateFile) {

        /*if (weixinPayProxy == null) {
            weixinPayProxy = new WeixinPayProxy(new WeixinPayAccount(id,paySignKey, mchId));
        }*/
    	if (weixinPayProxy == null) {
    	WeixinPayAccount mw =  new WeixinPayAccount(id,paySignKey, mchId,certificateKey,certificateFile);
            weixinPayProxy = new WeixinPayProxy(mw);
        }
        return weixinPayProxy;
    }
    
	
}
